<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/6/1
 * Time: 19:51
 * 后台用户信息表
 */

namespace Admin\Controller;
use Think\Controller;

class UserController extends CommonController
{

    private $users='';
    private $userAddress='';

    function __construct()
    {
        parent::__construct();
        $this->users=D('Users');
        $this->userAddress=D('userAddress');
    }

    function index(){

        if($_POST)
        {
            $promote_start_date=$_POST['startTime'];
            $yanG1=explode("-",$promote_start_date);
            $yanGstart=mktime(0,0,0,$yanG1[0],$yanG1[1],$yanG1[2]);      // 得到促销开始的时间戳
            $promote_end_date=$_POST['endTime'];
            $yanG2=explode("-",$promote_end_date);
            $yanGend=mktime(0,0,0,$yanG2[0],$yanG2[1],$yanG2[2]);      // 得到促销结束的时间戳
            if($yanGstart>=$yanGend)
            {
                $this->error("时间范围设置不正确","User/index");
            }else{
                $count=$this->users->where("reg_time>{$yanGstart} AND reg_time<{$yanGend}")->count();
                $Page=new \Think\Page($count,10);
                $nowPage=isset($_GET['p'])?$_GET['p']:1;
                $arr=$this->OrderInfo->where("reg_time>{$yanGstart} AND reg_time<{$yanGend}")->order(array('id','id'=>'desc'))->page($nowPage.','.$Page->listRows)->select();
            }
        }
        else
        {
            $count=$this->users->count();
            $Page=new \Think\Page($count,10);
            $nowPage=isset($_GET['p'])?$_GET['p']:1;
            $arr=$this->users->order(array('id','id'=>'desc'))->Page($nowPage.','.$Page->listRows)->select();
        }
        $show=$Page->show();
        $this->assign("data",$arr);
        $this->assign("pages",$show);
        $this->display();
    }
}